Signature
Parameters
str
required
Model identifier, potentially with schema prefix:
'ViT-B-32': Built-in model name.pretrainedspecifies CLIP weights source.'hf-hub:org/repo': Loads config/weights from HuggingFace Hub.'local-dir:/path/to/folder': Loads config/weights from local directory.
Optional[str]
default:"None"
Source for CLIP weights (tag or file path) ONLY if
model_name has no schema.bool
default:"True"
Load the resolved pretrained weights if True, otherwise random init or tower overrides only.
str
default:"'fp32'"
Model precision. Options:
'fp32', 'fp16', 'bf16', 'pure_fp16', 'pure_bf16'.Union[str, torch.device]
default:"'cpu'"
Device to load model on.
bool
default:"False"
If True, JIT compile the model.
bool
default:"False"
Force use of QuickGELU activation in model config.
bool
default:"False"
Force use of custom text encoder architecture.
Optional[float]
default:"None"
Override patch dropout value in model config.
Optional[Union[int, Tuple[int, int]]]
default:"None"
Override image size in model config.
Optional[int]
default:"None"
Override context length in text config.
Optional[Tuple[float, ...]]
default:"None"
Override default image normalization mean values (per channel). Example:
(0.48145466, 0.4578275, 0.40821073).Optional[Tuple[float, ...]]
default:"None"
Override default image normalization std values (per channel). Example:
(0.26862954, 0.26130258, 0.27577711).Optional[str]
default:"None"
Override default interpolation method for image resizing. Options:
'bicubic', 'bilinear', 'nearest'.Optional[str]
default:"None"
Override resize mode for preprocessing. Options:
'squash': Resize to exact dimensions (may distort aspect ratio)'shortest': Resize shortest edge to target size, then crop'longest': Resize longest edge to target size, then crop
Optional[Union[Dict[str, Any], AugmentationCfg]]
default:"None"
Augmentation configuration for training transforms. Can be dict or AugmentationCfg object. Controls random crop, color jitter, etc. If None, uses model defaults.Example dict:
{'scale': (0.9, 1.0), 'ratio': (1.0, 1.0), 'color_jitter': 0.4}bool
default:"False"
Load default base weights for image tower at creation if no CLIP weights loaded.
bool
default:"True"
Load default base weights for text tower at creation if no CLIP weights loaded.
Optional[str]
default:"None"
Path to load weights specifically into image tower after creation.
Optional[str]
default:"None"
Path to load weights specifically into text tower after creation.
Optional[str]
default:"None"
Cache directory for downloads.
Optional[bool]
default:"None"
If True and model supports it, return dict output.
bool
default:"True"
Use weights_only=True for torch.load (safer).
Any
Additional keyword arguments for model constructor.
Returns
torch.nn.Module
The created model instance.
Callable
Image preprocessing transform for training (includes augmentation like random crop, color jitter).
Callable
Image preprocessing transform for validation/inference (no augmentation, deterministic).
